package com.aphrodite.io;

import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;

import javax.microedition.io.Connector;

/**
 * FileWriter is an output stream for writing data to a file.
 */
public class FileWriter extends Writer {
	Writer out;

	/** Creates a new FileWriter. */
	public FileWriter(String filename) throws IOException {
		out = new OutputStreamWriter(Connector.openOutputStream("file://" + filename));
	}

	/** Close the stream. */
	public void close() throws IOException {
		out.close();
	}

	/** Flush the stream. */
	public void flush() throws IOException {
		out.flush();
	}

	/** Write an array of characters. */
	public void write(char[] cbuf) throws IOException {
		out.write(cbuf);
	}

	/** Write a portion of an array of characters. */
	public void write(char[] cbuf, int off, int len) throws IOException {
		out.write(cbuf, off, len);
	}

	/** Write a single character. */
	public void write(int c) throws IOException {
		out.write(c);
	}

	/** Write a string. */
	public void write(String str) throws IOException {
		out.write(str);
	}

	/** Write a portion of a string. */
	public void write(String str, int off, int len) throws IOException {
		out.write(str, off, len);
	}

}